package br.com.spread.svnutils;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import br.com.spread.svnutils.converters.DateConverter;

import com.thoughtworks.xstream.XStream;

public class XStreamMain {
	public static void main(String[] args) {
		XStream xstream = new XStream();

		xstream.registerConverter(new DateConverter(), 2);

		xstream.processAnnotations(new Class[] { Log.class });

		List<String> dirs = new ArrayList<String>();
		List<String> files = new ArrayList<String>();

		Log entry = (Log) xstream.fromXML(new File("logentry.xml"));
		for (LogEntry logEntry : entry.logEntries) {
			for (Path path : logEntry.paths) {
				if ("file".equals(path.kind) && !files.contains(path.value)) {
					files.add(path.value);
				}
				if ("dir".equals(path.kind) && !dirs.contains(path.value)) {
					dirs.add(path.value);
				}
			}
		}

		System.out.println();
		System.out.println("Dirs:");
		Collections.sort(dirs);
		for (String dir : dirs) {
			System.out.println(dir);
		}
		System.out.println();
		System.out.println("Files:");
		Collections.sort(files);
		for (String file : files) {
			System.out.println(file);
		}
	}
}
